<%@page import="java.util.UUID"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp" %>
<%
    String uuid = UUID.randomUUID().toString();
    request.setAttribute("uuid", uuid);
%>
<form  id="wordNumberEleForm" class="container-fluid am-margin-top">
	<input type="hidden" name="id"/>
	<input type="hidden" name="wnId"/>
	<input type="hidden" name="type" value="6"/>
	<input type="hidden" name="reg"/>
	
	<div class="form-group col-sm-12">
         <label for="title">名称</label>
         <input type="text" name="name" class="form-control">
     </div>
	<div class="form-group col-sm-12">
         <label for="title">KEY标识</label>
         <input type="text" name="key" class="form-control">
     </div>
     
	<div class="form-group pull-right">
         <a href="javascript:void(0)" id="wordNumberEleSubmitBt"  class="btn btn-primary">保存</a>
     </div>
</form>
<script type="text/javascript">
$(function(){
	var uuid = '${uuid}';
    var id = '${param.id}';
    var wordNumberEleForm=$("#wordNumberEleForm");
    
    if(id){
    	$.getJSON(ctx + '/wordNumberAct/findWordNumberEleById.do', {id: id}, function (data) {
            webUtils.fullForm({
                form: wordNumberEleForm,
                data: data
            });
            
            if(data.reg){
            	var reg=eval("("+data.reg+")");
            	if(!!reg){
    				if(reg.name){
    					wordNumberEleForm.find("input[name=name]").val(reg.name);
    				}
    				if(reg.key){
    					wordNumberEleForm.find("input[name=key]").val(reg.key);
    				}
    			}
            } 
        });
    }else{
    	var wnId='${param.wnId}';
    	wordNumberEleForm.find("input[name=wnId]").val(wnId);
    }
    
	$("#wordNumberEleSubmitBt").click(function(){
		var r="{name:'"+wordNumberEleForm.find("input[name=name]").val()+"',key:'"+wordNumberEleForm.find("input[name=key]").val()+"'}";
		wordNumberEleForm.find("input[name=reg]").val(r);
		
		wordNumberEleForm.ajaxSubmit({
            url: ctx + '/wordNumberAct/saveWordNumEle.do',
            data: {},
            type: "POST",
            success: function (data) {
                if (data.success) {
                    webUtils.alert("提交成功");
                    top.webUtils.topicPublish("wordNumberEle.edit.success", data);
                } else {
                	webUtils.error(data.msg);
                }
            }
        });
	});
})
</script>